<?php
(!defined('IN_SYSTEM') || !defined('ADMIN_PRE')) && exit('Access Denied!');
if(ican('sysview')){
$statistics = get_statistics();

$arccount = '共有文章 <font color="red">'.$statistics['arcnum'].'</font> 篇';
if ( $a = $_G['db']->result("SELECT COUNT(*) FROM ".DB_PREFIX."article WHERE `status` = 4") ) {
	$arccount .= '，其中有 <a href="admin.php?m=article&status=4"><b style="color:red">'.$a.'</b></a> 篇草稿。';
}
$cmtcount = '共有评论<font color="red"> '.$statistics['cmtnum'].' </font>条';
if ( $c = $_G['db']->result("SELECT COUNT(*) FROM ".DB_PREFIX."comment WHERE status = 0") ) {
	$cmtcount .= '，其中有 <a href="admin.php?m=comment&check=no"><b style="color:red">'.$c.'</b></a> 条等待审核。';
}

$file_upload = $statistics['max_upload'] == 'unknown' ? '<font color="red">禁止</font>' : '允许 '.$statistics['max_upload'];

$register_globals = $statistics['register_globals'] ? '<font color="red">开启</font>' : '关闭';
$gd_version = $statistics['gd_version'] == 'unknown' ? '<font color="red">不支持</font>' : '支持：'.$statistics['gd_version'];

}

include admintemplate('default');

function get_statistics() {
	global $_G;
	$db_size = 0;
	$result = $_G['db']->query("SHOW TABLE STATUS LIKE '".DB_PREFIX."%'");
	while ($table = $_G['db']->fetch_array($result)) {
		$db_size += $table['Data_length'] + $table['Index_length'];
	}
	$db_size = $db_size ? sizecount($db_size) : 'unknown';
	$attach_size = $_G['db']->result("SELECT SUM(filesize) AS size FROM ".DB_PREFIX."files");
	$attach_size = $attach_size ? sizecount($attach_size) : '0';
	$arcnum = $_G['db']->result("SELECT COUNT(*) FROM ".DB_PREFIX."article");
	$cmtnum = $_G['db']->result("SELECT COUNT(*) FROM ".DB_PREFIX."comment");
	$usernum = $_G['db']->result("SELECT COUNT(*) AS num FROM ".DB_PREFIX."users");
	$max_upload = @ini_get('file_uploads') ? ini_get('upload_max_filesize') : 'unknown';
	$register_globals = @ini_get('register_globals') ? 1 : 0;
	$gd_version = function_exists('gd_info') ? (is_array($gd=gd_info()) ? $gd['GD Version'] : '') : 'unknown';

	$statistics = array(
		'db_size' => $db_size,
		'attach_size' => $attach_size,
		'arcnum' => $arcnum,
		'cmtnum' => $cmtnum,
		'usernum' => $usernum,
		'server' => $_SERVER['SERVER_SOFTWARE'],
		'php' => PHP_VERSION,
		'mysql' => $_G['db']->version(),
		'sitename' => preg_replace('/[\'\"\s]/s', '', $_G['settings']['sitename']),
		'siteurl' => $_G['settings']['siteurl'],
		'gd_version' => $gd_version,
		'register_globals' => $register_globals,
		'max_upload' => $max_upload,
	);
	$statistics['update'] = rawurlencode(serialize($statistics));
	return $statistics;
}
?>